<template>
  <div class="header">
    <input type="text" v-model="newMsg">
    <button @click="add">确定</button>
  </div>
</template>

<script setup>
import { ref } from 'vue';

const newMsg = ref('')

const emits = defineEmits(['addMsg'])  // 定义
const add = () => {
  emits('addMsg', newMsg.value)  // 发布
}
</script>

<style lang="css" scoped>

</style>